# Copyright 2018-2022 Intel Corporation
# Copyright 2025 Hewlett Packard Enterprise Development LP
# All rights reserved.
#
# 'recipe' for Docker to build an environment scan DAOS for malware.
#

# Pull base image
ARG BASE_DISTRO=rockylinux/rockylinux:8
FROM $BASE_DISTRO
LABEL maintainer="daos@daos.groups.io"
# Needed for later use of BASE_DISTRO
ARG BASE_DISTRO

# Intermittent cache-bust.  Used to reduce load on the actual CB1 later.
ARG CB0

ARG REPO_FILE_URL
ARG JENKINS_URL
ARG REPOS
ARG DAOS_LAB_CA_FILE_URL
# script to translate lookup distro names to commonly used names
COPY ./utils/scripts/helpers/distro_info.sh /tmp/distro_info.sh
# script to install OS updates basic tools and maldet
COPY ./utils/scripts/helpers/install_maldet.sh /tmp/install.sh
# script to setup local repo if available
COPY ./utils/scripts/helpers/repo-helper-el8.sh /tmp/repo-helper.sh
RUN set -e;                                         \
    chmod +x /tmp/repo-helper.sh /tmp/install.sh && \
    /tmp/repo-helper.sh

# Add DAOS users
ARG UID=1000
COPY ./utils/scripts/helpers/daos-server-user-setup.sh \
     /tmp/daos-server-user-setup.sh
RUN set -e;                                    \
    chmod +x /tmp/daos-server-user-setup.sh && \
    /tmp/daos-server-user-setup.sh

# force an upgrade to get any newly built RPMs, but only if CB1 is set.
ARG CB1
RUN [ -z "$CB1" ] || {                                  \
        dnf upgrade &&                                  \
        dnf clean all;                                  \
    }

ARG BUILD_URL
COPY ./utils/scripts/helpers/build_url_repo.sh /tmp/build_url_repo.sh
RUN /tmp/build_url_repo.sh
